<?php
$myConfig = $DB->fetchAll('SELECT * FROM '.cms_db_prefix().'isubscribe_config');
$conf = array();
foreach($myConfig as $k=>$v){
    $conf[$v['k']] = $v['v'];
};

if(Antz_IntelliForm::submitted('config')){
    $newParams = array();
    foreach($_POST as $k=>$v){
        if($k=='smf_prefix') $v = trim($v, '/');
        $DB->update(cms_db_prefix().'isubscribe_config', array('v'=>$v), "k = '{$k}'");
    };
    Antz::addSuccess($this->Lang('settings_applied'));
}




$myConfig = $DB->fetchAll('SELECT * FROM '.cms_db_prefix().'isubscribe_config');


$form = Antz::newObject('Antz_Form', 'config');
$form->setAction($actionUrls['config']);
$block = $form->add('full');
$fs = $block->add($this->Lang('config_settings'));



// add all the other fields
foreach($myConfig as $k=>$row){
    if($row['field_type']=='boolean'){
        $fs->addLongTag('h2', $row['title']);
        $rad = $fs->addRadioGroup($row['k'], $row['v']);
        $rad->add('1', $this->Lang('yes'));
        $rad->add('0', $this->Lang('no'));
    }else if($row['field_type']=='page'){
    	//global $gCms;
    	//$contentOps = $gCms->GetContentOperations();
		//$sel = $contentOps->CreateHierarchyDropdown('', $row['v'], $row['k'], 0);
		//$fs->addLongTag('div', '<label>'.$row['title'].'</label>'.$sel.'('.$row['field_type'].')')->addClass('component');
	   $sel = $fs->addSelect($row['k'], $row['title'], $row['v']);
	   $Antz->addPagesToDropMenu($sel, -1, 0);
    }else{
        $inpt = $fs->addInput('text', $row['k'], $row['title'], $row['v']);
        $inpt->addAftertext('('.$row['field_type'].')');
        if($row['field_type']=='string') $inpt->addClass('extra-wide');
    }


};



$fs->addInput('submit', 'submitBtn', '&nbsp;', $this->Lang('update'));

echo $form->render();






